<%--
  Created by IntelliJ IDEA.
  User: tongjie
  Date: 2020/10/23
  Time: 9:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>TSearch</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-3">
                <h3>TSearch</h3>
            </div>
            <div class="col-md-6"></div>
            <div class="col-md-3">
                <%if(session.getAttribute("user")==null){%>
                <a class="btn btn-default" href="${pageContext.request.contextPath}/user/to_register" role="button">注册</a>
                <a class="btn btn-default" href="${pageContext.request.contextPath}/user/to_login" role="button">登录</a>
                <%}else{%>
                <div class="dropdown">
                    <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                        <li><a href="#">个人空间</a></li>
                        <li><a href="#">账号设置</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="${pageContext.request.contextPath}/user/cancell">退出</a></li>
                    </ul>
                </div>
                <%}%>
            </div>
        </div>
        <form class="form-inline" action="${pageContext.request.contextPath}/link/addLink" method="post">
            <div class="form-group">
                <label for="anchor">锚点</label>
                <input type="text" class="form-control" id="anchor" name="anchor" placeholder="锚点">
            </div>
            <div class="form-group">
                <label for="description">描述</label>
                <input type="text" class="form-control" id="description" name="description" placeholder="描述">
            </div>
            <button type="submit" class="btn btn-default">创建</button>
        </form>
    </div>
    <div class="container">
        <table class="table">
            <c:forEach begin="0" end="${requestScope.page.list.size()-1}" var="i">
            <tr>
                <td><a href="${requestScope.page.list[i].anchor}" target="_blank">${requestScope.page.list[i].anchor}</a></td>
                <td>${requestScope.page.list[i].description}</td>
                <td><a href="${pageContext.request.contextPath}/link/delete?id=${requestScope.page.list[i].id}">删除</a></td>
            </tr>
            </c:forEach>
        </table>
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <c:forEach begin="1" end="${requestScope.page.tpage}" var="i">
                    <li><a href="${pageContext.request.contextPath}/link/getPage?cpage=${i}&rows=5">${i}</a></li>
                </c:forEach>
            </ul>
        </nav>
    </div>

</body>
</html>
